// ------ 获取后端任务信息 ---------
function get_all_task(){
	mui.ajax('http://localhost:8080/task/alltaskquery',{
		data:{},
		dataType:'json',//服务器返回json格式数据
		type:'get',//HTTP请求类型
		timeout:10000,//超时时间设置为10秒；
		headers:{'Content-Type':'application/json'},
		success:function(data){
			if (data != null){
				// alert(data.tasks_info[0].name)
				list_all_task(data.tasks_info)	
			}
			else{
				alert("获取任务失败")
			}
		},
		error:function(xhr,type,errorThrown){
			alert("0000")
		}
	});
}

// 在任务栏中显示任务介绍
// Args: tasks_info [list]
function list_all_task(tasks_info){
	if (tasks_info == null){
		alert("0000")
		return 0
	}
	else{
		var box=document.getElementById("box");
		for (var i =0; i < tasks_info.length; i++) {
			var j = Math.floor(Math.random()*4)+1;
			box.innerHTML += '<li class="mui-table-view-cell"> <img class="mui-media-object mui-pull-left" src="images/slider'+j+'.jfif"> <p>'+ tasks_info[i].name +'</p> <p>'+ tasks_info[i].brief +'</p></li>';
			// if (i == 0) {
				// box.innerHTML += '<li class="mui-table-view-cell">' + tasks_info[i].brief + '</li>';
			// } else{
				box.childNodes[0].innerHTML += '<li class="mui-table-view-cell">' + tasks_info[i].brief + '</li>';
			// }
		}
	}
}


// --------------------------------------------------
// 调用位置
get_all_task()

